//
//  SqFinshViewCell.m
//  FengyuanXS
//
//  Created by 王冬 on 2020/8/4.
//  Copyright © 2020 王冬. All rights reserved.
//

#import "SqFinshViewCell.h"
#import "TypeCell.h"
@implementation SqFinshViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self initCollectionView];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initCollectionView{
   UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
        [flow setScrollDirection:UICollectionViewScrollDirectionHorizontal];//竖直滑动
    //    flow.minimumLineSpacing = 0;
    //    flow.minimumInteritemSpacing = 0;
        flow.itemSize = CGSizeMake(70, 70);
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.showsVerticalScrollIndicator = NO;
    self.collectionView.collectionViewLayout = flow;
    [self.collectionView registerNib:[UINib nibWithNibName:@"TypeCell" bundle:nil] forCellWithReuseIdentifier:@"TypeCell"];//注册cell
   
    
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
//    return self.treeList.count;
    return self.imageArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    TypeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TypeCell" forIndexPath:indexPath];
    PhotosModel *model = self.imageArray[indexPath.row];
    
//    [cell.backImageView sd_setImageWithURL:[NSURL URLWithString:@"%@%@",BaseImgUrl,model.url]];
    
    NSString * str1 = @"\\";
   NSString  *imageUrl = [model.url stringByReplacingOccurrencesOfString:str1 withString:@"/"];
    [cell.backImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",BaseImgUrl,imageUrl]]];
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
   // [self selectedIndex:indexPath.row withImageURLs:self.imageArray];
    
    if (self.selectItem) {
        self.selectItem(indexPath.row);
    }
}


@end
